<template>
  <view>
    <view class="card padding-30 margin-top-30">
			 <order-card v-for="(item,index) in list" :key="index" :item="item" type="pending" :margin-top="!index ? '0' : '30rpx'" />
    </view>
    <l-footer :has-more="hasMore" />

  </view>
</template>

<script>
import { pageOrder } from '../../api'
export default {
  name: 'PendingOrder',
  props: {
    info: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      list: [],
      page: 1,
      pageSize: 10,
      hasMore: true
    }
  },
  watch: {
    info: {
      handler() {
        this.getList()
      },
      deep: true
    }
  },
  methods: {
    async getList() {
      const [err, res] = await pageOrder({
        username: this.info.username,
        affiliatedBill: this.info.affiliatedBill,
        current: this.page,
        limit: this.pageSize
      })
      if (!this.$http.errorCheck(err, res)) return false
      const data = res.data.data
      let list = data.records
      if (!list) list = []
      if (list.length < this.pageSize) this.hasMore = false
      if (this.page === 1) this.list = list
      else this.list.push(...list)
      this.$emit('getSize', data.total)
      console.log(list)
    },
    reload() {
      this.hasMore = true
      this.page = 1
      this.getList()
    },
    nextPage() {
      if (this.hasMore) {
        this.page++
        this.getList()
      }
    }
  }
}
</script>

<style scoped>

</style>
